<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<style type="text/css">
.ui-widget {
	font-size: 12px !important;
}
</style>
</h:head>

<h:body>
	<ui:composition template="Layout.xhtml">
		<ui:define name="content">
			<h:form>
				<p:accordionPanel id="panel" autoHeight="false" dynamic="true" cache="true">

					<c:forEach items="#{events.eventList}" var="event">
						<p:tab title="#{event.name}">
							<p:messages />
							<h:panelGrid columns="2" cellpadding="10">
								<h:outputLabel value="Name: " />
								<h:outputText value="#{event.name}" />
								<h:outputLabel value="Datum: " />
								<h:outputText value="#{event.date}" />
								<h:outputLabel value="Genre: " />
								<h:outputText value="#{event.genre}" />
								<h:outputLabel value="Ort: " />
								<h:outputText value="#{event.location}" />
								<h:outputLabel value="Verfügbare Tickets: " />
								<h:outputText value="#{event.availableTickets}" />
								<h:outputLabel value="Preis pro Ticket: " />
								<h:outputText value="#{event.pricePerTicket}" />
								<h:outputText value="Schon gebucht!" rendered="#{sessionBean.loggedIn and sessionBean.eventBooked and !sessionBean.adminStatus}"/>
								<p:commandButton value="Buchen"
									action="book_event_frame?faces-redirect=true" rendered="#{sessionBean.loggedIn and !sessionBean.eventBooked and !sessionBean.adminStatus}">
									<f:setPropertyActionListener
										target="#{sessionBean.selectedEvent}" value="#{event}" />
								</p:commandButton>
								<p:commandButton value="Lotterie starten"
									action="#{lotteryBean.start}" rendered="#{sessionBean.adminStatus}" update="panel">
									<f:setPropertyActionListener
										target="#{sessionBean.selectedEvent}" value="#{event}" />
								</p:commandButton>
								<p:commandButton value="Bearbeiten"
									action="edit_event_frame?faces-redirect=true"
									rendered="#{sessionBean.adminStatus}">
									<f:setPropertyActionListener
										target="#{sessionBean.selectedEvent}" value="#{event}" />
								</p:commandButton>
								<p:commandButton value="Löschen" onclick="confirmation.show()"
									rendered="#{sessionBean.adminStatus}" update="panel">
									<f:setPropertyActionListener
										target="#{sessionBean.selectedEvent}" value="#{event}" />
								</p:commandButton>
							</h:panelGrid>
						</p:tab>
					</c:forEach>
				</p:accordionPanel>
				<p:confirmDialog message="Diese Event wirklich löschen?"
					showEffect="bounce" hideEffect="explode" header="Event löschen?"
					severity="alert" widgetVar="confirmation">

					<p:commandButton value="Ja" update="messages"
						oncomplete="confirmation.hide()"
						action="#{deleteEvent.submit}" />
					<p:commandButton value="Nein" onclick="confirmation.hide()"
						type="button" />

				</p:confirmDialog>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>